package com.syqc.adapter

import android.widget.ImageView
import androidx.core.view.isVisible
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.syqc.custom.LeftRightTextView
import com.syqc.entity.HistoryLine
import com.syqc.monitor.R


class StopLineAdapter(private val video: String?) :
    BaseQuickAdapter<HistoryLine.StopData, BaseViewHolder>(R.layout.item_line_stop) {
    init {
        addChildClickViewIds(R.id.tvStopAddr, R.id.ivVideo)
    }

    override fun convert(holder: BaseViewHolder, item: HistoryLine.StopData) {
        item.run {
            val position = holder.layoutPosition + 1
            val num = if (position < 10) "0$position" else "$position"
            holder.setText(R.id.tv_item_num, num)
            holder.getView<LeftRightTextView>(R.id.lrvStopStartTime).setRightText(startTime)
            holder.getView<LeftRightTextView>(R.id.lrvStopEndTime).setRightText(endTime)
            holder.getView<LeftRightTextView>(R.id.lrvStopDuration).setRightText(long)
            holder.setText(R.id.tvStopAddr, add)
            val ivVideo = holder.getView<ImageView>(R.id.ivVideo)
            ivVideo.isVisible = video != null
        }
    }
}